package com.newlink.building.common_base.utils

import com.newlink.building.common_base.base.BaseApplication
import com.newlink.building.common_base.ext.doNext
import com.newlink.building.common_base.http.Base_RetrofitHelper
import com.newlink.building.common_base.model.bean.VersionBean

/**
 * @Author: Jake
 * @Date: 2024-08-10
 * @Description:
 */
fun checkNewAppVersion(accessToken: String, result: (version: VersionBean?) -> Unit) {
    Base_RetrofitHelper.service.checkNewVersion(
        accessToken,
        Base_DeviceUtils.getAppVersion(BaseApplication.context),
        1,
    ).doNext(onCallback = {
        if (it.code == 200) {
            NLog.e("checkNewAppVersion: ${it.data}")
            result(it.data)
        } else {
            NLog.e("checkNewAppVersion: Failed")
            result(null)
        }
    }, onError = {
        result(null)
    })

}